Home | Printable Version
2.1: Forward Chaining
By default the rules are processed as they are listed. A more powerful option allows for the Rules Engine to be configured as a forward chaining engine. In this mode, it is much more of a data driven process: it processes its RuleBase using data from the FactBase. During this process, the FactBase will be updated. This can result in more rules being fired.
The forward chaining cycle can be described as follows:
Compare the rules against the data, and determine which rules are eligible to fire. A rule is eligible to fire when the if part of the rule evaluates to true. Determine a single rule to fire from the set of eligible rules. Each rule has a priority assigned to it, and the one with the highest priority (smallest number) will fire first. If two rules with the same priority become eligible to fire then one will be chosen arbitrarily to fire first. The selected rule is fired, which means the then part of the rule is executed; this may update the FactBase or call another part of the application. The above steps are repeated until no more rules are eligible to fire.
This can result in high priority (low number) rules being fired after much lower priority rules have fired. For example, you could write a high priority error checking rule, and a number of lower priority processing rules. If any of the rules causes an error, the high priority rule would be fired next to handle it accordingly. This forward chaining approach is different from the more traditional procedural approaches, and is disabled by default. You can enable forward chaining by ticking the Enable Forward Chaining option under rulebase settings.
RuleBase Settings Namespaces